#pragma once
#include"../LibDGGSBase/DGGSDefine.hpp"
#ifdef BUILDING_PYD
#include<vector>
#else
#include <memory>
namespace std {
    template <typename T, typename Allocator= allocator<T>>
    class vector;
}
#endif

namespace Json{
    class Value;
}

_NNU_DGGS_BEGIN
    namespace Kernel {
        _DGGS_Interface IDGGSKernel;
    }
using namespace Kernel;
using namespace Base;
namespace Feature {

    class DGGSFeatureClass;

    class DGGSFeature;

    /// <summary>
    /// 格网系统矢量的图层
    /// </summary>
    class DGGSFeatureLayer
    {
    private:
        DGGSFeatureClass*           _featureClass = nullptr;    //featureclass管理feature新建
        std::vector<DGGSFeature*>*  _features= nullptr;         //_features保存所有feature对象
        IDGGSKernel*                pKernel = nullptr;          //用于导入导出为json

        /// <summary>
        /// code转为json对象
        /// </summary>
        void code2JsonGeo(DGGSElementCode code,long long int featureId,Json::Value &feature);
    public:
        DGGSFeatureLayer();

        explicit DGGSFeatureLayer(DGGSFeatureClass &featureclass);

        ~DGGSFeatureLayer();

        /// <summary>
        /// 获取featureclass
        /// </summary>
        /// <returns>_featureClass</returns>
        DGGSFeatureClass* getFeatureClass(){return this->_featureClass;}

        /// <summary>
        /// 获取层级
        /// </summary>
        /// <returns>int Level</returns>
        int getLevel();

        /// <summary>
        /// 根据索引获取feature
        /// </summary>
        /// <returns>DGGSFeature*</returns>
        DGGSFeature* getFeature(int featureIndex);

        /// <summary>
        /// 添加feature
        /// </summary>
        bool addFeature(DGGSFeature* feature);

        /// <summary>
        /// 删除feature
        /// </summary>
        bool eraseFeature(DGGSFeature* feature);

        /// <summary>
        /// 获取feature数量
        /// </summary>
        /// <returns>int Count</returns>
        int getFeatureCount();

        /// <summary>
        /// 导出为json文件
        /// </summary>
        void saveToFile(const char* fileName);

        /// <summary>
        /// 从json文件导入
        /// </summary>
        bool loadFromFile(const char* fileName);
    };

}
_NNU_DGGS_END